找传奇、传世资源到传世资源站!

C#调用科大讯飞语音转写语音合成的接口

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

非常好用 我就不贴图了
from clipboardusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using iFlyDotNet;using NAudio.Wave;using Microsoft.DirectX.DirectSound;namespace demoTTS{ public partial class Form1 : Form { bool luyin = true; WaveInStream wi; private WaveFileWriter writer; iFlyISR isr; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { button1.Enabled = false; string c1 = "appid=53f4099e"; iFlyTTS tts = new iFlyTTS(c1); tts.Finished = tts_Finished; tts.vol = enuVol.x_loud; tts.speed = enuSpeed.medium; tts.speeker = (enuSpeeker)comboBox1.SelectedIndex; tts.MultiSpeek(textBox1.Text, "audio.wav"); button1.Enabled = true; } void tts_Finished(object sender, iFlyTTS.JinDuEventArgs e) { System.Diagnostics.Debug.WriteLine(e.AllP.ToString()); } private void Form1_Load(object sender, EventArgs e) { foreach (string s in Enum.GetNames(typeof(enuSpeeker))) comboBox1.Items.Add(s); comboBox1.SelectedIndex = 0; } private void button2_Click(object sender, EventArgs e) { button2.Enabled = false; string c1 = "server_url=dev.voicecloud.cn,appid=53f4099e,timeout=10000"; string c2 = "sub=iat,ssm=1,auf=audio/L16;rate=16000,aue=speex,ent=sms16k,rst=plain"; isr = new iFlyISR(c1, c2); isr.DataArrived = new EventHandler<iFlyISR.DataArrivedEventArgs>(asr_DataAvailable); isr.ISREnd = new EventHandler(Isr_ISREnd); isr.Audio2TxtAsync("audio.wav", null); } void Isr_ISREnd(object sender, EventArgs e) { button2.Invoke(new MethodInvoker(delegate() { button2.Enabled = true; })); } void asr_DataAvailable(object sender, iFlyISR.DataArrivedEventArgs e) { textBox1.Invoke(new MethodInvoker(delegate() { textBox1.AppendText(e.result); })); } private void button3_Click(object sender, EventArgs e) { if (luyin) { luyin = false; //wi = new WaveInStream(0, new WaveFormat(16000, 16, 1), this); //wi.DataAvailable = new EventHandler<WaveInEventArgs>(wi_DataAvailable); //writer = new WaveFileWriter("audio.wav", wi.WaveFormat); //wi.StartRecording(); string c1 = "server_url=dev.voicecloud.cn,appid=53f4099e,timeout=10000"; string c2 = "sub=iat,ssm=1,auf=audio/L16;rate=16000,aue=speex,ent=sms16k,rst=plain"; isr = new iFlyISR(c1, c2); isr.DataArrived = new EventHandler<iFlyISR.DataArrivedEventArgs>(asr_DataAvailable); isr.ISREnd = new EventHandler(Isr_ISREnd); isr.StartRecoding(); button3.Text = "停止录音"; } else { luyin = true; //wi.StopRecording(); //wi.Dispose(); //wi = null; //writer.Close(); //writer.Dispose(); //writer = null; isr.StopRecoding(); button3.Text = "开始录音"; } } void wi_DataAvailable(object sender, WaveInEventArgs e) { writer.WriteData(e.Buffer, 0, e.BytesRecorded); } private void button4_Click(object sender, EventArgs e) { System.Media.SoundPlayer sp = new System.Media.SoundPlayer("audio.wav"); sp.Play(); } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复